package com.itheima.service.impl;

import com.itheima.entity.Student;
import com.itheima.mapper.StudentMapper;
import com.itheima.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;


    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public List<Student> findAll() {
        return studentMapper.findAll();
    }

    @Override
    @Transactional(propagation = Propagation.SUPPORTS)
    public Student findById(Integer id) {
        return studentMapper.findById(id);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public Integer deleteById(Integer id) {
        return studentMapper.deleteById(id);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public Integer add(Student student) {
        return studentMapper.add(student);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED)
    public Integer update(Student student) {
        return studentMapper.update(student);
    }
}
